﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WaterCooler.Models;
using Wolfbyte.Core.Repositories;

namespace WaterCooler.Controllers
{
    public class HomeController : Controller
    {
        IRepository<Conversation> conversationRepository;

        public HomeController(IRepository<Conversation> conversationRepository)
        {
            this.conversationRepository = conversationRepository;
        }

        public ActionResult Index()
        {
            ViewData["Title"] = "Home Page";
            ViewData["Message"] = "Welcome to ASP.NET MVC! Conversation Count: " + conversationRepository.Items.Count();
            ViewData["Conversations"] = conversationRepository.Items.OrderBy(c => c.Name).ToArray();

            return RenderView();
        }

        public ActionResult About()
        {
            ViewData["Title"] = "About Page";

            conversationRepository.Add(new Conversation() { Name = "About" });

            return RenderView();
        }
    }
}
